CREATE SEQUENCE S_APPRAISALS;

CREATE SEQUENCE S_EVALITEMS;

CREATE SEQUENCE S_EVALSETTINGS;

CREATE SEQUENCE S_EVALSHEETS;

CREATE SEQUENCE S_QUESTIONITEMS;

CREATE SEQUENCE S_QUESTIONTYPES;

CREATE SEQUENCE S_SHEETITEMS;

CREATE SEQUENCE S_STUDENTEVALS;

CREATE SEQUENCE S_TEMPLATES;

CREATE SEQUENCE S_EVALRATE;

CREATE TABLE APPRAISALS  (
   RID                  INTEGER                         NOT NULL,
   MIN                  NUMBER,
   MAX                  NUMBER,
   CONTENT              NVARCHAR2(2000),
   ELID                 INTEGER,
   CONSTRAINT PK_APPRAISALS PRIMARY KEY (RID)
);

CREATE TABLE EVALITEMS  (
   RID                  INTEGER                         NOT NULL,
   EVALNAME             NVARCHAR2(50)                   NOT NULL,
   REMARKS              NVARCHAR2(2000),
   CONSTRAINT PK_EVALITEMS PRIMARY KEY (RID)
);

CREATE TABLE EVALSETTINGS  (
   RID                  INTEGER                         NOT NULL,
   DESTID               INTEGER                         NOT NULL,
   TASKIDLIST           VARCHAR2(200),
   RESEARCHIDLIST       VARCHAR2(200),
   GRADELIST            VARCHAR2(200),
   CONSTRAINT PK_EVALSETTINGS PRIMARY KEY (RID)
);

CREATE TABLE EVALSHEETS  (
   RID                  INTEGER                         NOT NULL,
   DESTID               INTEGER                         NOT NULL,
   TEMPLATEID           INTEGER                         NOT NULL,
   SHEETNAME            NVARCHAR2(50)                   NOT NULL,
   EVALDATE             DATE,
   SCORE                NUMBER(8,2),
   DIRTY                SMALLINT,
   STUDENTEVAL          SMALLINT,
   SEID                 INTEGER,
   CREATOR              INTEGER,
   CONSTRAINT PK_EVALSHEETS PRIMARY KEY (RID)
);

CREATE TABLE QUESTIONITEMS  (
   RID                  INTEGER                         NOT NULL,
   QTTYPEID             INTEGER,
   QICONTENT            NVARCHAR2(2000),
   QIOPTS               XMLTYPE,
   QIPOSITION           INTEGER,
   QISCORE              NUMBER,
   QITYPE               SMALLINT,
   CONSTRAINT PK_QUESTIONITEMS PRIMARY KEY (RID)
);

CREATE TABLE QUESTIONTYPES  (
   RID                  INTEGER                         NOT NULL,
   TEMPLATEID           INTEGER,
   QTNAME               NVARCHAR2(100),
   QTPOSITION           INTEGER,
   CONSTRAINT PK_QUESTIONTYPES PRIMARY KEY (RID)
);

CREATE TABLE SHEETITEMS  (
   RID                  INTEGER                         NOT NULL,
   ESID                 INTEGER,
   SCORE                NUMBER(8,2),
   DETAIL               XMLTYPE,
   REMARKS              VARCHAR2(2000),
   AUTHORID             INTEGER,
   AUTHORNAME			NVARCHAR2(50),
   CONSTRAINT PK_SHEETITEMS PRIMARY KEY (RID)
);

CREATE TABLE STUDENTEVALS  (
   RID                  INTEGER                         NOT NULL,
   SENAME               NVARCHAR2(50),
   STARTDATE            DATE,
   ENDDATE              DATE,
   TEMPLATEID           INTEGER,
   CAUSEIDLIST          NVARCHAR2(200),
   SCHOOLYEAR			INTEGER,
   TERM					INTEGER,
   STATE 				INTEGER,
   CONSTRAINT PK_STUDENTEVALS PRIMARY KEY (RID)
);

CREATE TABLE TEMPLATES  (
   RID                  INTEGER                         NOT NULL,
   EVALITEMID           INTEGER,
   TEMPLATENAME         NVARCHAR2(50),
   TEMPLATESTYLE        SMALLINT,
   EVALTYPE             SMALLINT,
   TEMPLATELEVEL        INTEGER,
   CONSTRAINT PK_TEMPLATES PRIMARY KEY (RID)
);

CREATE TABLE EVALRATE
(
  RID  INTEGER NOT NULL,
  EIID INTEGER,
  RATE NUMBER,
  CONSTRAINT PK_EVALRATE PRIMARY KEY (RID)
);

CREATE TABLE TEMP_PERSON_SINGLE_REPORT 
(
  RID INTEGER,
  SHEETNAME NVARCHAR2(50),
  EVALDATE DATE,
  SCORE NUMBER(8,2),
  MAX NUMBER,
  TEMPALTENAME NVARCHAR2(50),
  APPRAISALS NVARCHAR2(2000)
);

CREATE TABLE TEMP_PERSON_SUMMARY_REPORT 
(
  RID INTEGER,
  EVALITEMNAME NVARCHAR2(50),
  SCORE NUMBER(8,2),
  MAX NUMBER,
  RATE NUMBER,
  APPRAISALS NVARCHAR2(2000)
);

CREATE TABLE TEMP_SINGLE_SUMMARY_REPORT (
  RID INTEGER,
  NAME NVARCHAR2(20),
  CODE NVARCHAR2(20),
  SCORE NUMBER(8,2),
  MAX NUMBER,
  APPRAISALS NVARCHAR2(2000)
);

CREATE TABLE TEMP_REPORT_REPORTSUMM (
  RID INTEGER,
  TEACHCODE NVARCHAR2(50),
  TEACHNAME NVARCHAR2(50),
  SCORE NUMBER(8,2),
  SUMSCORE NUMBER,
  PERCENTUM FLOAT
);